// Copyright [2020] <unknown>
#include <bits/stdc++.h>
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
using namespace std;
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

const int N = 5e4+50;


struct P {
    int first, second, another;
    explicit P(int first = 0, int second = 0, int another = 0)
        : first(first), second(second), another(another) {
        }
    bool operator < (const P &other) const {
        return first != other.first ?
            first < other.first : second < other.second;
    }
};

int n;

int t, r, c;

char s[N];


set<P> rb[N], cb[N];


void extend(set<P> *S, set<P>::iterator it) {
    auto p = S->find(P(it->another));
    assert(p != S->end());
    P np(p->first + 1, p->second, p->another);
    if (it->second == -1) {
        np.first -= 2;
    }
    S->erase(p);
    S->insert(np);
}

void merge(set<P> *S, set<P>::iterator l, set<P>::iterator r, int left) {
    if (l->second == -1 && r->second == 1 && l->first == r->first) {
        S->erase(l);
        auto it = S->lower_bound(P(r->another, -1));
        P np = *it;
        np.another = left;
        S->erase(it);
        S->insert(np);
        S->erase(r);
    }
}

void insertPoint(set<P> *S, int p) {
    P tar(p, -1);
    auto l = S->lower_bound(tar), r = S->upper_bound(tar);
    int left = -1;
    if (l != S->end() && r != S->end() && l->second == 1 && r->second == -1)
        return;
    if (l != S->end() && l->first == p && l->second == -1) {
        left = l->another;
        S->erase(l);
    } else {
        left = p;
        S->insert(P(p, 1, p+1));
    }
    S->insert(P(p+1, -1, left));
    l = S->lower_bound(P(p+1, -100));
    assert(l != S->end());
    assert(l->second == -1);
    if (r != S->end()) {
        assert(r->second == 1);
        merge(S, l, r, left);
    }
}

void maintain(int nr, int nc) {
    insertPoint(&rb[nc], nr);
    insertPoint(&cb[nr], nc);
}

int main(int argc, char const *argv[]) {
    scanf("%d", &t);
    for (int kk = 0; kk < t; ++kk) {
        int nr, nc;
        scanf("%d%d%d%d%d", &n, &r, &c, &nr, &nc);
        scanf("%s", s);
        for (int i = 1; i <= c; ++i)
            rb[i].clear();
        for (int i = 1; i <= r; ++i)
            cb[i].clear();
        insertPoint(&rb[nc], nr);
        insertPoint(&cb[nr], nc);
        for (int i = 0; i < n; ++i) {
            char op = s[i];
            if (op == 'N') {
                nr = rb[nc].upper_bound(P(nr, 2))->another;
                --nr;
            } else if (op == 'S') {
                nr = rb[nc].upper_bound(P(nr, 2))->first;
            } else if (op == 'W') {
                nc = cb[nr].upper_bound(P(nc, 2))->another;
                --nc;
            } else if (op == 'E') {
                auto p = cb[nr].upper_bound(P(nc, 2));
                assert(p != cb[nr].end());
                nc = p->first;
            }
            maintain(nr, nc);
        }
        printf("Case #%d: %d %d\n", kk+1, nr, nc);
    }
    return 0;
}
